package reflect;

import java.util.Arrays;

/**
 * Java中的变长参;
 */
public class Demo04Args {
    public static void main(String... args) {
        doSome(1);
        doSome(2,"A");
        doSome(666,"A", "B");
        doSome(5,"A", "B", "C");
        doSome(8,"A", "B", "C", "D", "E", "F", "G");
        doSome(3,"A", "B", "C", "D", "E", "F", "G", "H", "I", "J");
    }

    /**
     * 1.变长参写法: 方法名(参数类型... 参数名);
     * 2.变长参是以数组方式接收传递的参数;
     * 3.变长参是Java编译器认可,但是虚拟机不认可,在编译阶段会把 ... 编译为数组方式,交由虚拟机执行;
     * 4.变长参前面也可以加一个或者多个参数,但是变长参数必须为最后一个;
     */
    public static void doSome(int a, String... s){
        System.out.println(s.length);
        System.out.println(Arrays.toString(s));
    }
}












